package com.litelimit.core.limit;

import com.litelimit.core.strategy.core.LimitMethod;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.util.concurrent.TimeUnit;

/**
 * 基本配置
 */
@Data
@ConfigurationProperties(prefix = "lite-limit")
public class LiteLimitProps {
    private boolean enable = true;         // 是否开启
    private String logLevel = "INFO";      // 日志等级
    private boolean autoAddController = false;      // 是否加在所有的Controller层
    private GlobalConfig[] globalConfigs = {new GlobalConfig()};

    @Data
    @AllArgsConstructor
    @NoArgsConstructor
    public static class GlobalConfig {
        private String group = "";
        private LimitMethod strategy = LimitMethod.LIMIT_IP;
        private String key = "";
        private int period =  1;
        private TimeUnit unit = TimeUnit.SECONDS;
        private int max = 60;
    }
}
